package ReflectStudy.Exa5;

import java.awt.Container;
import java.util.TreeSet;

import javax.swing.JComponent;
import javax.swing.JPanel;

public class Test {
    /**
     * 测试前，我们需要知道，JPanel extends JComponent extends Container
     * @param args
     */
    public static void main(String[] args) {
        TreeSet<Class<?>> treeSet = new TreeSet<Class<?>>(new ClassComparator());
        System.out.println("向树集中添加JPanel.class");
        treeSet.add(JPanel.class);// 向树集中添加JPanel.class
        System.out.println("向树集中添加JComponent.class");
        treeSet.add(JComponent.class);// 向树集中添加JComponent.class
        System.out.println("向树集中添加Container.class");
        treeSet.add(Container.class);// 向树集中添加Container.class
        System.out.println("获得排序后的Class：");
        for(Class<?> cl:treeSet){
            System.out.println(cl);
        }
    }
}
